<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\models\Region */
/* @var $form yii\widgets\ActiveForm */
?>
<?=Html::jsFile('/static/backend/js/pinYin.js')?>
<div class="region-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'name')->textInput(['onkeyup' => 'hzToPY(this)', 'onpaste' => 'hzToPY(this)', 'onkeydown' => 'hzToPY(this)']) ?>
    <?= $form->field($model, 'pid')->hiddenInput()->label(false) ?>
    <?= $form->field($model, 'name_pinyin')->textInput(['id' => 'pinyin']) ?>

    <?= $form->field($model, 'order')->textInput() ?>

    <?= $form->field($model, 'is_hot')->dropDownList(\common\helpers\TStringHelper::getYesOrNo()) ?>
    <?= $form->field($model, 'is_index')->dropDownList(\common\helpers\TStringHelper::getYesOrNo()) ?>
    <?= $form->field($model, 'status')->dropDownList(\common\helpers\TStringHelper::getStatusText()) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('common', 'create') : Yii::t('common', 'update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
<script>
    function hzToPY(obj){
        var py = ConvertPinyin(obj.value);
        $("#pinyin").val(py);
    }
</script>